// src/controller/shoop.controller.ts
import { Controller, Get, Param } from '@nestjs/common';
import { ShoopService } from '../service/shoop.service';
import { Shoop } from '../service/shoop.service'; // 从service文件导入
import { log } from 'console';

@Controller('shoops')
export class ShoopController {
  constructor(private readonly shoopService: ShoopService) {}

  /**
   * 获取所有商品列表
   * GET /shoops
   */
  @Get()
  getAllShoops(): Shoop[] {
    return this.shoopService.getAllShoops();
  }

  /**
   * 根据ID获取商品
   * GET /shoops/:id
   */
  @Get(':id') // 修复：去掉多余的点，应该是 :id
  getShoopById(@Param('id') id: string): Shoop | null { // 修复：|| 改为 |
    const shoopId = parseInt(id, 10);
    return this.shoopService.getShoopById(shoopId);
    
  }
}